<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class GameCommodity extends Model
{
    public $timestamps = false;
    protected $table = 'base_game_commodity';


    /**
     * 修改
     * @param $gameCommodity
     * @param $request
     * @return array
     */
    static function GameCommodityModify($gameCommodity, $request)
    {
        $gameCommodity->name = $request->name;
        $gameCommodity->img_url = $request->img_url;
        $gameCommodity->content = $request->contents;
        if (!$gameCommodity->save()) {
            return ['status' => 2, 'message' => '修改失败'];
        }

        return ['status' => 1, 'message' => '修改成功'];
    }

    /**
     * 添加
     * @param $game_id
     * @param $request
     * @return array
     */
    static function GameCommodityPublish($game_id, $request)
    {
        $gameCommodity = new GameCommodity();
        $gameCommodity->game_id = $game_id;
        $gameCommodity->name = $request->name;
        $gameCommodity->img_url = $request->img_url;
        $gameCommodity->content = $request->contents;
        if (!$gameCommodity->save()) {
            return ['status' => 2, 'message' => '添加失败'];
        }

        return ['status' => 1, 'message' => '添加成功'];
    }
}
